package insight;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.TimeUnit;

public class Main {
    public static void main(String[] args) {
        MyThreadPool myThreadPool = new MyThreadPool(
                2,
                4,
                1,
                TimeUnit.SECONDS,
                new ArrayBlockingQueue<Runnable>(2),
                new ExceptionRejuctHandle());
        for (int i = 0; i < 15; i++) {//因为在第7个任务抛出异常，只有前6个被接受，后续任务无法执行
            myThreadPool.execute(()->{
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                System.out.println(Thread.currentThread().getName() + "在执行任务");
            });
        }
        System.out.println("不是主线程在执行任务");
    }
}